package com.beiding.demo.bean;

import com.beiding.mpTimer.Executor;
import com.beiding.mpTimer.TaskPersistence;
import com.beiding.mpTimer.TimerShaftService;

public class ExecutorImpl extends Executor {


    private TimerShaftService timerShaftService;

    public ExecutorImpl(TimerShaftService timerShaftService) {
        this.timerShaftService = timerShaftService;
    }

    @Override
    protected void onSuccess(TaskPersistence persistence) {

        //执行成功就删除
        timerShaftService.remove(persistence.getId());

    }

    @Override
    protected void onException(TaskPersistence persistence, Exception exception) {

        System.err.println("任务处理器未捕获,默认的异常处理--" + exception.toString() + "负载为:" + persistence.getPayload());

    }

    @Override
    protected void onNoSuchHandler(TaskPersistence persistence) {
        System.err.println("没有这种类型的处理器--" + "负载为:" + persistence.getPayload());
    }
}
